﻿<my:FloatingWindow
    xmlns:my="clr-namespace:SilverFlow.Controls;assembly=SilverFlow.Controls"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:local="clr-namespace:SilverlightDebateView"
	xmlns:SilverlightDebateViewModel="clr-namespace:SilverlightDebateViewModel;assembly=SilverlightDebateViewModel"
	xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
	xmlns:SilverlightDebateView_Classes="clr-namespace:SilverlightDebateView.Classes"
	xmlns:PopupBehaviorProto="clr-namespace:PopupBehaviorProto"
	xmlns:SilverlightDebateView_Views="clr-namespace:SilverlightDebateView"
	mc:Ignorable="d"
	x:Class="SilverlightDebateView.Statement"
	d:DesignWidth="640" d:DesignHeight="480" Width="500" Height="400">
    <my:FloatingWindow.Resources>
    	<SilverlightDebateView_Classes:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
    	<SilverlightDebateView_Classes:TrueToFalseConverter x:Key="TrueToFalseConverter"/>
    	<SilverlightDebateView_Classes:LoginVisibleConverter x:Key="LoginVisibleConverter"/>
    	<DataTemplate x:Key="OpinionTemplate6">
    		<StackPanel Orientation="Horizontal" d:DesignWidth="144" d:DesignHeight="40">
    			<StackPanel Orientation="Vertical" HorizontalAlignment="Left">
    				<StackPanel Orientation="Horizontal">
    					<TextBlock Text="{Binding ObjOpinion._Title}"/>
    				</StackPanel>
    				<StackPanel d:LayoutOverrides="Width" Orientation="Horizontal">
    					<TextBlock Text="{Binding ObjOpinion._PostedBy}"/>
    					<TextBlock Text="{Binding ObjOpinion._UpdatedOn}" FontStretch="Condensed" FontSize="8"/>
    				</StackPanel>
    			</StackPanel>
    			<StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Right">
    				<TextBlock Text="{Binding ObjOpinion._SupportCount}" HorizontalAlignment="Left"/>
    				<Button Command="{Binding SupportOpinionCommand}" Visibility="{Binding VMStatementViewModel.CanVote, Converter={StaticResource BoolToVisibilityConverter}}">
    					<i:Interaction.Triggers>
    						<i:EventTrigger EventName="Click">
    							<i:InvokeCommandAction Command="{Binding VMStatementViewModel.LoadAgreeOpinionsCommand}"/>
    							<i:InvokeCommandAction Command="{Binding VMStatementViewModel.LoadDisagreeOpinionsCommand}"/>
    						</i:EventTrigger>
    					</i:Interaction.Triggers>
    					<TextBlock TextWrapping="Wrap" Text="Agree"/>
    				</Button>
    			</StackPanel>
    		</StackPanel>
    	</DataTemplate>
    </my:FloatingWindow.Resources>
	<i:Interaction.Triggers>
		<i:EventTrigger EventName="Closing">
			<i:InvokeCommandAction Command="{Binding VMMainPageViewModel.VMStatementsViewModel.GetSelectedStatementCommand}"/>
		</i:EventTrigger>
	</i:Interaction.Triggers>

    <my:FloatingWindow.DataContext>
        <SilverlightDebateViewModel:StatementViewModel/>
    </my:FloatingWindow.DataContext>

    <Grid x:Name="LayoutRoot" >
        <i:Interaction.Triggers>
        	<i:EventTrigger>
        		<i:InvokeCommandAction x:Name="loadDisagreeOnLoad" Command="{Binding LoadDisagreeOpinionsCommand}"/>
        		<i:InvokeCommandAction x:Name="loadAgreeOnLoad" Command="{Binding LoadAgreeOpinionsCommand}"/>
        	</i:EventTrigger>
        	<ei:PropertyChangedTrigger Binding="{Binding CanVote}">
        		<i:InvokeCommandAction x:Name="UpdateStats" Command="{Binding ReloadStatementCommand}"/>
        	</ei:PropertyChangedTrigger>
        	<i:EventTrigger EventName="Loaded">
        		<i:InvokeCommandAction x:Name="canvote1" Command="{Binding CheckCanVoteCommand}"/>
        	</i:EventTrigger>
        	<i:EventTrigger EventName="GotFocus">
        		<i:InvokeCommandAction x:Name="canvote2" Command="{Binding CheckCanVoteCommand}"/>
        	</i:EventTrigger>
        </i:Interaction.Triggers>
        <Grid x:Name="disagrees" HorizontalAlignment="Right" Margin="0,85,8,41" Width="235">
        	<ListBox ItemTemplate="{StaticResource OpinionTemplate6}" ItemsSource="{Binding DisagreeOpinionsList, Mode=TwoWay}" Margin="8,32,0,3"/>
        </Grid>
        <TextBlock Margin="7,67,0,0" TextWrapping="Wrap" Text="SUPPORT" VerticalAlignment="Top" HorizontalAlignment="Left" Width="114" FontWeight="Bold" Foreground="#FF0862B4"/>
        <TextBlock Margin="0,67,7,0" TextWrapping="Wrap" Text="OPPOSE" VerticalAlignment="Top" HorizontalAlignment="Right" Width="56" FontWeight="Bold" Foreground="#FFF30000"/>
        <Grid x:Name="agrees" HorizontalAlignment="Left" Margin="6,85,0,41" Width="235">
            <ListBox ItemsSource="{Binding AgreedOpinionsList, Mode=TwoWay}" Margin="8,32,0,3" ItemTemplate="{StaticResource OpinionTemplate6}"/>
        </Grid>
        <TextBlock Text="{Binding SelectedStatement.StatementContent}" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Margin="10,27,10,0" Height="35"/>
        <StackPanel Height="29" Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,87,0,0">
            <TextBlock Margin="0,0,5,0" TextWrapping="Wrap" Width="24" Text="{Binding SelectedStatement.AgreeCount}" VerticalAlignment="Center"/>
            <ProgressBar Margin="0,5" Background="Red" Foreground="#FF0441FF" Maximum="{Binding TotalVotes}" SmallChange="1" Value="{Binding SelectedStatement.AgreeCount}" Width="414"/>
            <TextBlock Margin="5,0,0,0" TextWrapping="Wrap" Width="24" Text="{Binding SelectedStatement.DisagreeCount}" VerticalAlignment="Center"/>
        </StackPanel>
        <Button Content="Undo Vote" HorizontalAlignment="Left" Margin="110,0,0,9" VerticalAlignment="Bottom" Width="75" IsEnabled="{Binding CanVote, Converter={StaticResource TrueToFalseConverter}}" Visibility="{Binding VMMainPageViewModel.RIAAuthenticationHeaderProperty, Converter={StaticResource LoginVisibleConverter}}">
            <i:Interaction.Triggers>
            	<i:EventTrigger EventName="Click">
            		<i:InvokeCommandAction Command="{Binding ResetVoteCommand}"/>
            		<i:InvokeCommandAction Command="{Binding CheckCanVoteCommand}"/>
            	</i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
        <Button Content="New Opinion" HorizontalAlignment="Left" Margin="15,0,0,9" VerticalAlignment="Bottom" Width="88" Visibility="{Binding VMMainPageViewModel.RIAAuthenticationHeaderProperty, Converter={StaticResource LoginVisibleConverter}}" IsEnabled="{Binding CanVote}">
        	<i:Interaction.Triggers>
        		<i:EventTrigger EventName="Click">
        			<i:InvokeCommandAction Command="{Binding SetNewOpinionReturnICommand}"/>
        			<i:InvokeCommandAction Command="{Binding CheckCanVoteCommand}"/>
        		</i:EventTrigger>
        	</i:Interaction.Triggers>
        </Button>
        <TextBlock Text="{Binding SelectedStatement.Title}" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5" Margin="10,2,10,0" Height="25"/>
    </Grid>
</my:FloatingWindow>
